package ewu

import ewu._

/**
 * Diese Klasse erbt von der Comparison-Klasse und
 * stellt einen Kleiner-Vergleich dar.
 * Beispiel: x < y
 */

case class Lesser (left: Expression, right: Expression) extends Comparison {
  
  def evaluate (env: Environment): Option[Boolean]
                                   = (left.evaluate(env), right.evaluate(env)) match {
    case (Some(le), Some(ri)) => Some(le < ri)
    case _ => None
  }
  
  override def toString: String = left + " < " + right

  def reduce: BoolExpression = Lesser(left.reduce, right.reduce)

  def isTrue: Boolean = (left.reduce, right.reduce) match {
    case (n1: Number, n2: Number) => n1.value < n2.value
    case _ => false
  }
  
}


 